<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>水壶问题</title>
</head>
<body>
  <script>
    function fn(x, y, z) {
      if (z > x + y || z < 0) return false;
      if (z === 0) return true;
      if (x === 0 || y === 0) return x + y === z;
      let res = (a, b) => {
        if (b === 0) return a
        return res(b, a % b)
      }
      return z % (res(x, y)) === 0
    }
    console.log(fn(3, 5, 4))
  </script>
</body>
</html>